package com.example.andro40test;

import java.util.EventListener;

import cc.cwfan.utils.*;
import cc.cwfan.event.*;
import android.R.integer;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class HomeFragment extends Fragment implements OnClickListener{

	private MyEventListener myEventListener = null;
	
	@Override
	public View getView() {
		// TODO Auto-generated method stub
		return super.getView();
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onActivityCreated(savedInstanceState);
		Button btn = null;
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_1);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_2);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_3);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_4);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_5);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_6);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_7);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_8);
		btn.setOnClickListener(this);
		btn = (Button)this.getActivity().findViewById(R.id.home_fragment_btn_9);
		btn.setOnClickListener(this);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_home, container, false);
	}
	
	
	@Override
	public void onClick(View arg0) {
		
		if (myEventListener != null)
			myEventListener.onFire(arg0,arg0.getTag().toString());
		
		
	}
	
	public void setBtnOnFireListener(MyEventListener listener){
		myEventListener = listener;
	}

}
